/*****************************************************************************/
/**
 *  @file   ResourceMonitor.h
 *  @author Naohisa Sakamoto
 */
/*----------------------------------------------------------------------------
 *
 *  Copyright (c) Visualization Laboratory, Kyoto University.
 *  All rights reserved.
 *  See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details.
 *
 *  $Id: ResourceMonitor.h 80 2013-12-06 04:04:09Z naohisa.sakamoto $
 */
/*****************************************************************************/
#pragma once

#include <cstdio>
#include <string>
#include <kvs/SharedPointer>
#include <kvs/cuda/Device>


/*===========================================================================*/
/**
 *  @brief  Resource monitoring class.
 */
/*===========================================================================*/
class ResourceMonitor
{
private:

    kvs::SharedPointer<kvs::cuda::Device> m_device;

    static size_t m_default_number_of_gpus;
    static size_t m_default_total_gpu_memory;
    static size_t m_default_free_gpu_memory;

public:

    static void SetDefaultNumberOfGPUs( const size_t ngpus );
    static void SetDefaultTotalGPUMemory( const size_t bytes );
    static void SetDefaultFreeGPUMemory( const size_t bytes );

    ResourceMonitor( const size_t device_id = 0 );

    void update();
    size_t numberOfCPUs() const;
    size_t numberOfGPUs() const;
    size_t totalCPUMemory() const;
    size_t freeCPUMemory() const;
    size_t totalGPUMemory() const;
    size_t freeGPUMemory() const;
};
